/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vision.IndexingImagenes;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;

/**
 *
 * @author juanagva
 */
public class FrameIndexing extends javax.swing.JFrame {

    /**
     * Creates new form FrameIndexing
     */
    JFileChooser fc = new JFileChooser();
    String directory = "" ;
    
    static List<String> lista = Arrays.asList("Auto Color Correlogram","CEDD Document","Color Histogram","Color Layout",
      "Default Document","Edge Histogram"
        ,"FastAutoColorCorrelation","FCTHD","FullDocument","GaborDocument","JCDDocument","JpegCoefficientHistogramDocument"  
        ,"ScalableColor","TamuraDocument");
   
    
   
    

    public void setjComboBox1(List<String> lista) 
    {
        this.jComboBox1.removeAllItems();
        for(String item : lista )
        {
           this.jComboBox1.addItem(item); 
        }
        
    }  

   

    
    
    
    public String getDirectory() {
        return directory;
    }

    public void setDirectory(String directory) {
        this.directory = directory;
    }

  
    public FrameIndexing() {
        initComponents();
        
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jLabel3 = new javax.swing.JLabel();
        jComboBox1 = new javax.swing.JComboBox();
        jSeparator1 = new javax.swing.JSeparator();
        jLabel4 = new javax.swing.JLabel();
        jButton2 = new javax.swing.JButton();

        jLabel1.setText("jLabel1");

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel2.setText("Elegir la ubicación de la base de datos");

        jButton1.setText("Elegir la Ubicacion");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jLabel3.setText(".....");

        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        jLabel4.setText("Eliga la caracteristica por analizar");

        jButton2.setText("Generar el Indixe");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(24, 24, 24)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel3)
                            .addComponent(jButton1)
                            .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 196, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel4))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 366, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(223, 223, 223)
                        .addComponent(jButton2)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4))
                .addGap(18, 18, 18)
                .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(35, 35, 35)
                .addComponent(jButton2)
                .addContainerGap(90, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        fc.setAcceptAllFileFilterUsed(false);        
        int returnVal = fc.showOpenDialog(this);

        if (returnVal == JFileChooser.APPROVE_OPTION) {
             directory  = fc.getSelectedFile().toString();
             this.jLabel3.setText(directory);
            System.out.println(directory);
           
        } else {
            System.out.println("no se selecciono ningun directorio");
        }  
      this.setjComboBox1(lista);    
        
        
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed

        ImagenIndexamiento index = new ImagenIndexamiento();
        index.dirlist(directory);
         try 
         {
                String opcion = this.jComboBox1.getSelectedItem().toString();
                if (opcion.equals("Auto Color Correlogram"))
                {
                    index.setIndexPath("Auto-Color");
                        index.DefaultImplementacion("Auto Color Correlogram");
                }
                if (opcion.equals("CEDD Document"))
                {
                    index.setIndexPath("CEDD-Document");
                        index.DefaultImplementacion("CEDD Document");
                }
                if (opcion.equals("Color Histogram"))
                {
                    index.setIndexPath("Color-Histogram");
                        index.DefaultImplementacion("Color Histogram");
                }
                 if (opcion.equals("Color Layout"))
                {
                    index.setIndexPath("Color-Layout");
                        index.DefaultImplementacion("Color Layout");
                }
                  if (opcion.equals("Default Document"))
                {
                    index.setIndexPath("Default-Document");
                        index.DefaultImplementacion("Default Document");
                }
                   if (opcion.equals("Edge Histogram"))
                {
                    index.setIndexPath("Edge-Histogram");
                        index.DefaultImplementacion("Edge Histogram");
                } 
                 if (opcion.equals("FCTHD"))
                {
                     index.setIndexPath("FCTHD");
                        index.DefaultImplementacion("FCTHD");
                } 
                 if (opcion.equals("FullDocument"))
                {
                    index.setIndexPath("FullDocument");
                        index.DefaultImplementacion("FullDocument");
                } 
                 if (opcion.equals("GaborDocument"))
                {
                     index.setIndexPath("GaborDocument");
                        index.DefaultImplementacion("GaborDocument");
                }   
                 if (opcion.equals("JCDDocument"))
                {
                    index.setIndexPath("JCDDocument");
                        index.DefaultImplementacion("JCDDocument");
                }
                  if (opcion.equals("JpegCoefficientHistogramDocument"))
                {
                     index.setIndexPath("JpegCoefficientHistogramDocument");
                        index.DefaultImplementacion("JpegCoefficientHistogramDocument");
                }
                   if (opcion.equals("ScalableColor"))
                {
                     index.setIndexPath("ScalableColor");
                        index.DefaultImplementacion("ScalableColor");
                }
                   
                    if (opcion.equals("TamuraDocument"))
                {
                    index.setIndexPath("TamuraDocument");
                        index.DefaultImplementacion("TamuraDocument");
                }
        } 
         catch (IOException ex) 
         {
                Logger.getLogger(FrameIndexing.class.getName()).log(Level.SEVERE, null, ex);
          }
        
    }//GEN-LAST:event_jButton2ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(FrameIndexing.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(FrameIndexing.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(FrameIndexing.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(FrameIndexing.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new FrameIndexing().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JSeparator jSeparator1;
    // End of variables declaration//GEN-END:variables
}
